home *** CD-ROM | disk | FTP | other *** search
/ Know Your Hockey - The Greatest Player Resource / Know Your Hockey: The Greatest Player Resource.iso / hockey / director / ktgcst.cst / 00045_Script_PopUpMenu Script--using Movie in a window < prev    next >
Text File  |  1998-09-28  |  4KB  |  143 lines

  1. -- the popup menu is a separate movie that is openined over the current movie
  2. -- the global gPop stores the name of the popup window
  3.  
  4. global gPop,gPopButtonState,gSubPop
  5.  
  6.  
  7. -- launches and positions the popup menu
  8.  
  9. -- popname = file name & the window's name
  10. -- posV = the window's vertical position
  11. -- posh = the window's horizontal position
  12. -- W = width
  13. -- h = height
  14. -- level defines which pop menus will close 
  15. --  level 1 all
  16. -- level 2 only those above 1 etc.
  17.  
  18. on InitPopMenu popname,posV,posH,W,H,level
  19.   puppetsound 0
  20.   resetbanner
  21.   if voidp(gpop) then set gpop = []
  22.   losePop (window level)
  23.   if the result > 0 then exit
  24.   set temp = window popname
  25.   set the filename of temp to popname 
  26.   set the windowtype of temp to 2
  27.   FindCurentStageLocation posV,posH,W,H, temp
  28.   open temp
  29.   -- check to see if it is has been created
  30.   --  pause the correct windows
  31.   -- I didn't use the window list to this
  32.   set c = getone(gPop temp)
  33.   if c = 0 then append gPop temp
  34.   set s = getone(gPop temp)
  35.   case s of
  36.     1: tell the stage to pause
  37.       set the mousedownscript to "limitedfunction"
  38.     2:
  39.       tell  getat(gpop,1) to set the mousedownscript to "limitedfunctionPoP"
  40.       tell getat(gpop,1) to pause
  41.     3:
  42.       tell getat(gpop,2) to pause
  43.   end case 
  44. end
  45.  
  46.  
  47. -- examines the current location of the stage  then positions the popup window correctly
  48.  
  49. on FindCurentStageLocation posV,posH,W,H,temp
  50.   set x = the rect of the stage
  51.   set topX = posH+value(the left of x) -- position on stage offset by the stage pos on the screen
  52.   set topY = PosV+value(the top of x)-- position on stage offset by the stage pos on the screen
  53.   set BottomX = H+topX-- bottom corner = top corner plus desired window size (in bold)
  54.   set BottomY = W+TopY--bottom corner = top corner plus desired window size (in bold)
  55.   -- set BottomLeft = value(item 3 of temp)
  56.   -- set BottomRight = value(item 4 of temp)
  57.   set the rect of temp to rect(TopX,TopY,BottomX,BottomY)
  58. end
  59.  
  60. -- closes  all the popup menus
  61.  
  62. on LosePop level
  63.   if gpop = [] then 
  64.     return 0
  65.     exit
  66.   end if
  67.   
  68.   -- if the exit is present when subpop called close it first
  69.   set a =getone(gPop,(window "exit"))
  70.   
  71.   if  level = (window "subpop") and a > 0 then 
  72.     Close (window "exit")
  73.     Forget (window "exit")
  74.     deleteat(gPop,a)
  75.   end if
  76.   
  77.   set start = getone(gPop,level)
  78.   
  79.   if start = 0 then exit 
  80.   set range = count(gPop) 
  81.   repeat with x = range down to start
  82.     set popout = getat(gPop,x)
  83.     Close popout
  84.     forget popout
  85.   end repeat
  86.   
  87.   repeat with x = range down to start
  88.     deleteat(gPop,x)
  89.   end repeat
  90.   
  91.   
  92.   
  93.   -- check to see what windows still exist and make the top one
  94.   -- active again
  95.   set t = count(gPop)
  96.   case t of
  97.     0:  continue
  98.       bgmusic
  99.       resetbanner
  100.       set the mousedownscript to EMPTY
  101.       
  102.     1:
  103.       set active = getat(gpop,1)
  104.       tell active to continue
  105.     2: 
  106.       set active = getat(gpop,2)
  107.       tell active to continue
  108.   end case 
  109.   return start
  110. end
  111.  
  112.  
  113. -- this script is assigned to the mousedown for the stage when a pop
  114. -- menu is open and dismissed when it is closed
  115. -- it only allows clicks to the background and the ball button to
  116. -- dismiss the pop menus
  117. -- this script is assigned to the mousedown for the stage when a pop
  118. -- menu is open and dismissed when it is closed
  119. -- it only allows clicks to the background and the ball button to
  120. -- dismiss the pop menus
  121. -- variables
  122. --     a = a list containing the sprite numbers of buttons to exempt
  123. --     b = the current button clicked
  124. on limitedfunction 
  125.   set a =[1,39]
  126.   set b = the clickon
  127.   repeat with x in a
  128.     set t = x
  129.     if b = t then 
  130.       set exempt = 1
  131.       exit repeat
  132.     end if
  133.   end repeat
  134.   if exempt = 1 then
  135.     continue
  136.     Pass
  137.   else
  138.     losepop(window "pop")
  139.     dontPassEvent
  140.   end if
  141.   
  142. end
  143.